package com.zzyl.serve.controller.member;

import com.zzyl.common.core.controller.BaseController;
import com.zzyl.common.core.domain.AjaxResult;
import com.zzyl.common.core.domain.R;
import com.zzyl.serve.domain.DeviceData;
import com.zzyl.serve.dto.DeviceDataDayDto;
import com.zzyl.serve.dto.ElderDto;
import com.zzyl.serve.dto.HealDto;
import com.zzyl.serve.dto.ElderDto;
import com.zzyl.serve.dto.HealDto;
import com.zzyl.serve.dto.UserLoginRequestDto;
import com.zzyl.serve.vo.*;
import com.zzyl.serve.service.IFamilyMemberService;
import com.zzyl.serve.vo.*;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.poi.ss.formula.functions.T;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 * 老人家属Controller
 * 
 * @author itheima
 * @date 2025-03-12
 */
@RestController
@RequestMapping("/member/user")
@Api(tags = "老人家属相关接口")
public class FamilyMemberController extends BaseController
{
    @Autowired
    private IFamilyMemberService familyMemberService;


    /**
     * 小程序端 用户登录
     */
    @PostMapping("/login")
    @ApiOperation("小程序端 用户登录")
    public R<LoginVo> login(@RequestBody UserLoginRequestDto dto) {

        LoginVo vo = familyMemberService.login(dto);
        return R.ok(vo);
    }

    /**
     * 1.1 绑定家人
     * 接口地址:/member/user/add
     * 请求方式:POST
     */
    @PostMapping("/add")
    @ApiOperation("绑定家人")
    public AjaxResult addFamily(@RequestBody ElderDto dto){
         familyMemberService.addFamily(dto);
        return success();
    }
    /**
     * 1.2 查询家人列表
     * 接口地址:/member/user/my
     * 请求方式:GET
     * 请求参数: 无
     */
    @GetMapping("/my")
    @ApiOperation("查询家人列表")
    public R<List<FamilyVo>> findFamily(){
      List<FamilyVo> list = familyMemberService.findFamily();
        return R.ok(list);
    }
    /**
     * 1.3 查看家人列表（分页查询）
     * 接口地址:/member/user/list-by-page
     * 请求方式:GET
     * 请求参数:
     * 请求参数:
     */

    @GetMapping("/list-by-page")
    @ApiOperation("查询家人列表")
    public R<List<AllFamilyVo>> findByPage(Integer pageNum, Integer pageSize){
       List<AllFamilyVo> list = familyMemberService.findByPage(pageNum,pageSize);
        return R.ok(list);
    }
    /**
     * 1.4 查询健康数据
     * 接口地址:/member/user/QueryDevicePropertyStatus
     * 请求方式:POST
     */
    @PostMapping("/QueryDevicePropertyStatus")
    @ApiOperation("查询家人列表")
    public R<OneVo>QueryDevicePropertyStatus(@RequestBody HealDto dto){
        OneVo list= familyMemberService.QueryDevicePropertyStatus(dto);
        return R.ok(list);
    }

    /**
     * 按天统计查询指标数据
     */
    @GetMapping("/queryDeviceDataListByDay")
    @ApiOperation("按天统计查询指标数据")
    public R<List<DeviceDataDayVo>> queryDeviceDataListByDay(DeviceDataDayDto dto) {
        List<DeviceDataDayVo> list = familyMemberService.queryDeviceDataListByDay(dto);
        return R.ok(list);
    }


    @GetMapping("/queryDeviceDataListByWeek")
    @ApiOperation("按周统计查询指标数据")
    public R<List<DeviceDataWeekVo>> queryDeviceDataListByWeek() {
        List<DeviceDataWeekVo> list = familyMemberService.queryDeviceDataListByWeek();
        return R.ok(list);
    }
}
